<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/css/font.css">
        <link rel="stylesheet" href="/css/xadmin.css">
        <script src="/js/common.js" charset="utf-8"></script>
        <script src="/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/js/xadmin.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">会员管理</a>
                <a><cite>会员列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5">
                              
                                <div class="layui-inline layui-show-xs-block">
                                    <input class="layui-input" autocomplete="off" placeholder="开始日" name="start" id="start">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input class="layui-input" autocomplete="off" placeholder="截止日" name="end" id="end">
                                </div>

                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="username" id="userName" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                        <i class="layui-icon">&#xe615;</i>
                                    </button>
                                    <button class="layui-btn" id="sreach" data-type="reload">搜索</button>
                                </div>

                            </form>
                        </div>
                        <div class="layui-card-header">
                            <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
                            <button class="layui-btn" onclick="xadmin.open('添加用户','./member-add.html',600,400)"><i class="layui-icon"></i>添加</button>
                        </div>

                        <div class="layui-card-body ">
                            <table class="layui-table" id="tableList"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script type="text/html" id="toolbarDemo">
        <div class = "layui-btn-container" > 
            <button class = "layui-btn layui-btn-sm" lay-event = "getCheckData" > 获取选中行数据 </button>
            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button > 
            <button class = "layui-btn layui-btn-sm" lay-event = "isAll" > 验证是否全选</button>
        </div > 
    </script>
    <script type="text/html" id="switchTpl">
        <!-- 这里的checked的状态只是演示 -->
        <input type="checkbox" name="autoSin" value="{{d.isopenautosign}}" lay-skin = "switch"lay-text = "是|否" lay-filter = "sexDemo" {{ d.isopenautosign == 0 ? '': 'checked'}} >
    </script>

    
    <script>layui.use('laydate',
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });

        });</script>
    <script>
    layui.use('table',
        function() {

            var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , vipTable = layui.vip_table
            ,$=layui.jquery;


            table.render({
                elem: '#tableList',
                url : BASE_URL+'/getUserList',
                method : 'post',
                // where :{holder: '涛仔'},
                id: 'tableReload',
                page: true,
                limit: 20,
                parseData: function (res) {  
                    return{
                        "code":  0, //解析接口状态
                        "data": res.dataList, //解析数据列表
                        "count": res.totalNum, //解析数据长度
                    }
                },
                cols: [[
                    {field:'id', width:80, title: 'ID', sort: true}
                    ,{field:'phone', width:120, title: '手机号', sort: true}
                    // ,{field:'pwd', width:120, title: '密码'}
                    ,{field:'signtime', title: '签到时间', align : 'center', minWidth: 150 , templet: "<div>{{layui.util.toDateString(d.ordertime, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
                    ,{field:'isopenautosign', width:120, title: '是否自动签到' ,align : 'center',templet: switchTpl}
                    ,{field:'opentime', title: '开通时间', align : 'center', minWidth: 150 , templet: "<div>{{layui.util.toDateString(d.ordertime, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
                    ,{field:'endtime', title: '到期时间', align : 'center', minWidth: 150 , templet: "<div>{{layui.util.toDateString(d.ordertime, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
                    ,{field:'signstatus', width:120, align : 'center',title: '签到状态' ,templet: function(d){ return d.signstatus == 1 ? '已签到' : '未签到';}, sort: true}
                    ,{field:'ksye', width:80, align : 'center',title: '可售余额'}
                    ,{field:'ut', width:80,align : 'center', title: 'UT', sort: true}
                    ,{field:'ksed', width:100,align : 'center', title: '可售额度', sort: true}
                    ,{field:'kczc', width:80,align : 'center', title: '矿池资产'}
                    ,{field:'holder', width:80, title: '归属人', align : 'center'}
                ]]
            })
            
            //监听性别操作
            form.on('switch(sexDemo)', function(obj){
                layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            });

            //监听提交
            form.on('submit(sreach)', function(data){
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
                return true;
            });

             //搜索功能的实现
        // $('.demoTable .layui-btn').on('click', function () {
        //     var type = $(this).data('type');
        //     active[type] ? active[type].call(this) : '';
        // });


            var $ = layui.$, active = {
                reload: function(){
                    var username = $('#userName');
                    var usernameVal = username.val()
                    //执行重载
                    table.reload('tableReload', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        ,where: {
                            holder: usernameVal
                        }
                    }, 'data');
                }
            };
            
            // $('#sreach').on('click', function(){
            //     var type = $(this).data('type');
            //     active[type] ? active[type].call(this) : '';
            // });
        });
        </script>


</html>